if_name=$1

Interfaces=`ifconfig -a "$if_name" \
    | grep -o -e "[a-z][a-z]*[0-9]*[ ]*Link" \
    | perl -pe "s|^([a-z]*[0-9]*)[ ]*Link|\1|"`

for Interface in $Interfaces; do
    INET=`ifconfig $Interface | grep -o -e "inet addr:[^ ]*" | grep -o -e "[^:]*$"`
    MASK=`ifconfig $Interface | grep -o -e "Mask:[^ ]*"      | grep -o -e "[^:]*$"`
    STATUS="up"
    if [ "$INET" == "" ]; then
        INET="-"
        MASK="-"
        STATUS="down";
    fi
    printf "%s %s %s %s\n" "$Interface" "$INET" "$MASK" "$STATUS"
done
